<template>
  <div class="app-container">
    资产销毁
    <el-form label-width="120px">
      <el-form-item label="资产地址">
        <el-input v-model="assetId"/>
      </el-form-item>
      <el-form-item label="合约地址">
        <el-input v-model="contractId"/>
      </el-form-item>
      <el-form-item label="合约名称">
        <el-input v-model="contractName"/>
      </el-form-item>
      <el-form-item label="同意者数组">
        <el-input v-model="froms"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="destroy()">销毁</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import carMold from '@/api/carMold'
export default {
  data() {
    return {
      carControllerVo: {},
      assetId: '',
      contractId: '',
      contractName: '',
      froms: ''
    }
  },
  created() {
  },
  methods: {
    // 添加
    destroy() {
      this.carControllerVo = {}
      this.carControllerVo.contractId = this.contractId
      this.carControllerVo.contractName = this.contractName
      this.carControllerVo.froms = this.handleFroms(this.froms)
      carMold.destroy(this.assetId, this.carControllerVo)
        .then(response => {
          // 提示
          this.$message({
            type: 'success',
            message: '销毁成功!'
          })
          // 跳转列表页面，使用路由跳转方式实现
          this.$router.push({ path: '/asset/findAllAsset' })
        })
    },
    // 对用户输入的同意者数组String转成Array，用户输入以','分割
    handleFroms(froms) {
      return froms.split(',')
    }
  }
}
</script>
